package com.dl.mood.db;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.dl.mood.dao.MoodDao;
import com.dl.mood.model.MoodItem;

@Database(entities = {MoodItem.class}, version = 2, exportSchema = false)
public abstract class MoodDatabase extends RoomDatabase {
    public abstract MoodDao moodDao();

    private static volatile MoodDatabase INSTANCE;

    public static MoodDatabase getInstance(Context context) {
        if (INSTANCE == null) {
            synchronized (MoodDatabase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
                                    MoodDatabase.class, "mood_database")
                            .build();
                }
            }
        }
        return INSTANCE;
    }
}


